import time

from appium import webdriver


#准备5个参数
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.common.by import By

param={
  "deviceName": "127.0.0.1:62001",#设备号
  "platformName": "Android",#系统名称
  "platformVersion": "7.1.2",#系统版本
  "appPackage": "com.baidu.wenku",#软件包名
  "appActivity": "com.baidu.wenku.splash.view.activity.WelcomeActivity"#启动类名
}

url= "http://127.0.0.1:4723/wd/hub"

driver=webdriver.Remote(url,param)
time.sleep(5)
TouchAction(driver).tap(x=615, y=1097).perform()
time.sleep(2)
TouchAction(driver).tap(x=303, y=249).perform()
time.sleep(2)
el1 = driver.find_element(MobileBy.ID,"com.baidu.wenku:id/h5_search_edit_text_inside")
el1.send_keys("中元节习俗")
time.sleep(2)
el2 = driver.find_element(MobileBy.ID,"com.baidu.wenku:id/h5_search_operate_text")
el2.click()
time.sleep(2)
el3 = driver.find_element(MobileBy.XPATH,
  "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[3]/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View[1]/android.view.View[1]/android.view.View/android.view.View")
el3.click()
time.sleep(2)
TouchAction(driver).press(x=577, y=1495).move_to(x=582, y=744).release().perform()


driver.quit()